package com.ruike.alisurface.ui.realAuth;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.ruike.alisurface.R;
import com.ruike.alisurface.base.BaseAty;
import com.ruike.alisurface.bean.CarGoodsBeans;
import com.ruike.alisurface.bean.ShopOrderBean;
import com.ruike.alisurface.ui.ShopMain_Aty;
import com.ruike.alisurface.ui.adapters.ShopPayAdapter;
import com.ruike.alisurface.utils.FinalDbUtils;
import com.ruike.alisurface.utils.GsonUtils;
import com.voodoo.lib_logcat.L;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 选择认证页
 */
public class SelectIDcardAuth_Aty extends BaseAty {


    @BindView(R.id.sleid_times)
    TextView sleidTimes;
    @BindView(R.id.sleid_shop_rcv)
    RecyclerView authShopRcv;


    @Override
    protected int getLayoutResId() {
        return R.layout.app_select_idcardauth;
    }

    @Override
    protected void initViews() {
        initTitleBar(false);
        startCountdownTimer(60, sleidTimes, ShopMain_Aty.class);
    }

    ShopOrderBean shopOrderBean;//订单数据
    List<CarGoodsBeans> goodsBeansList = new ArrayList<>();//商品集合数据
    String json;

    @Override
    protected void initData() {
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            json = getIntent().getStringExtra("shopOrderBean");
            shopOrderBean = GsonUtils.fromJson(json, ShopOrderBean.class);
        }
        goodsBeansList.addAll(FinalDbUtils.getInstance().findAll(CarGoodsBeans.class));
        ShopPayAdapter shopPayAdapter = new ShopPayAdapter(R.layout.pay_shop_list_item, goodsBeansList, this);
        authShopRcv.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
        authShopRcv.setAdapter(shopPayAdapter);
        L.i("订单信息==", goodsBeansList.toString());

    }

    @OnClick({R.id.sleid_back, R.id.sleid_giveup_tv, R.id.sleid_realname_tv})
    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {

            case R.id.sleid_back:
            case R.id.sleid_giveup_tv:
                startActivity(ShopMain_Aty.class, null);
                finish();
                break;
            case R.id.sleid_realname_tv:
                doStartActivity(RealNameAuth_Aty.class, json);
                break;

        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //释放数据
        shopOrderBean = null;
        json = null;
        goodsBeansList.clear();
    }
}
